package com.gouda.core.dao;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.gouda.core.entity.TagsEntity;
import com.gouda.core.enums.GeneralStateEnum;
import org.amethyst.atlas.db.MagicDao;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by KGL on 2015/12/7.
 */
@Repository
public class TagsDao extends MagicDao {
    private static final String BASE_SQL = " select id,tag_name,tag_type from tags ";

    /**
     * 根据服务类型查询标签
     * @param serviceTypeId
     * @return
     */
    public List<TagsEntity> lookupRemarkTags(final long serviceTypeId) {
        if(serviceTypeId <= 0L) {
            return Lists.newArrayList();
        }

        final String whereSql = " where st_id=:stId and stat=:stat ";
        final String querySql = BASE_SQL + whereSql;

        final Map<String,Object> params = Maps.newHashMap();
        params.put("stId", serviceTypeId);
        params.put("stat", GeneralStateEnum.YES.getCode());

        return super.list(TagsEntity.class, querySql, params);
    }

}
